package com.weipai.springboot.module.controller;

import com.weipai.springboot.model.GiftCertificate;
import com.weipai.springboot.model.Shop;
import com.weipai.springboot.model.api.Response;
import com.weipai.springboot.module.service.GiftCertificateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/08/04 15:30
 * 
 * 礼券管理类
 */
@RestController
public class GiftCertificateController {
    
    @Autowired
    GiftCertificateService giftCertificateService;

    /**
     * 分页查询  ----------------------------------领券中心
     * @param page 页码
     * @param size 每页条数
     *             draw------------------------征用为 customerId
     */
    @GetMapping("/giftCertificate/list/{page}/{size}/{draw}")
    public Response list(@PathVariable("page") Integer page,
                         @PathVariable("size") Integer size,
                         @PathVariable("draw") String draw){
        return giftCertificateService.selectAllByPage(page, size, draw);
    }

    // 后台管理页面 -- 礼券管理 - 列表 -  条件不一样 需要重写
    @GetMapping("/giftCertificate/list22/{page}/{size}/{draw}")
    public Response list22(@PathVariable("page") Integer page,
                         @PathVariable("size") Integer size,
                         @PathVariable("draw") String draw){
        return giftCertificateService.selectAllByPage22(page, size, draw);
    }





    /**
     * 添加礼券
     * @param giftCertificate
     * @return
     */
    @PostMapping("/giftCertificate/save")
    public Response save(GiftCertificate giftCertificate){
        return giftCertificateService.save(giftCertificate);
    }

    /**
     * 查询礼券详情
     * @param id:礼券id
     * @return
     */
    @GetMapping("/giftCertificate/getGiftCertificateById/{id}")
    public Response getGiftCertificateById(@PathVariable("id")  String id){
        return giftCertificateService.getGiftCertificateById(id);
    }

    /**
     * 删除
     * @param id:礼券id
     * @return
     */
    @DeleteMapping("/giftCertificate/deleteById/{id}")
    public Response deleteById(@PathVariable("id")  String id){
        return giftCertificateService.deleteById(id);
    }

    /**
     * 更改礼券的状态--启用/禁用
     * @param id:礼券id
     * @return
     */
    @GetMapping("/giftCertificate/changeStatus/{id}/{status}")
    public Response changeStatus(@PathVariable("id")  String id,
                                            @PathVariable("status")  Integer status){
        return giftCertificateService.changeStatus(id, status);
    }

    /**
     * 修改礼券
     * @param giftCertificate
     * @return
     */
    @PutMapping("/giftCertificate/update")
    public Response update(GiftCertificate giftCertificate){
        return giftCertificateService.update(giftCertificate);
    }

    /**
     * 批量删除
     * @param id:积分商品的id集合
     * @return
     */
    @DeleteMapping("/giftCertificate/batchDeleteById/{id}")
    public Response batchDeleteById(@PathVariable("id")  String[] id){
        return giftCertificateService.batchDeleteById(id);
    }



    
}
